<?php 
	echo Request::current()->uri(array('project_id' => '223'));
	echo Helper_Auth::instance()->get_user_displayname();
	$projects = Model::factory('project')->get_all_project(Helper_Auth::instance()->get_user_id());
?>

<ul>
	
	<li class="first">Project   
		<select name="project_id" id="project">
			<option value="<?php echo Request::current()->uri(array('project_id' => (isset($project) ? $project['id'] : '')))?>"><?php echo (isset($project) ? $project['name'] : 'ALL')?></option>
			<?php foreach ($projects as $p):?>
				<?php if(!isset($project)||$p['id'] != $project['id']):?>
				<option value="<?php echo Request::current()->uri(array('project_id' => $p['id']))?>"><?php echo $p['name']?></option>
				<?php endif;?>
			<?php endforeach;?>
		</select>
	</li>
	<li>Type   
		<select name="project_type" id="project_type">
			<option value="">NULL</option>
			<option value="<?php echo Helper_MyConst::TECHNICAL?>">Technical</option>
			<option value="<?php echo Helper_MyConst::GENERAL?>">General</option>
			<option value="<?php echo Helper_MyConst::FINANCE?>">Finance</option>
		</select>
	</li>
	<li>
		Priority   
		<select name="project_priority" id="project_priority">
			<option value="">NULL</option>
			<option value="<?php echo Helper_MyConst::PRIORITY_HIGH?>">High</option>
			<option value="<?php echo Helper_MyConst::PRIORITY_MEDIUM?>">Medium</option>
			<option value="<?php echo Helper_MyConst::PRIORITY_LOW?>">Low</option>
		</select>
	</li>
</ul>

<script type="text/javascript">
	$('#project').change(function(){
		var link = '/'+$('#project').val();
		window.location = link;
	});
	$('#project_type').change(function(){
		$("#project_type").attr('disbaled', true);
		var str = '/ajax/ses/save_session/?key=<?php echo 'project_type';?>&value='+$("#project_type").val();
		alert(str);
		$.ajax({
			url: str,
			success: function(ret) {
					var data = $.parseJSON(ret);
					if (data.success)
						window.location = '/<?php echo Request::current()->uri(array('project_id' => NULL))?>';
			},
			error: function() {
				alert('Error occured!');
			},
			complete: function() {
			}
		});
		return false;	
	});
	$('#project').change(function(){
		var link = '/'+$('#project').val();
		window.location = link;
	});
</script>